package com.example.springboot_demo.pojo;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class Dog extends Animal{

    private Integer age;

    @Override
    public void eat() {
        System.out.println("狗吃");
    }

    public static void main(String[] args) {
        Dog dog = new Dog();
        dog.setName("aa");
        dog.setId(1L);
        dog.setAge(19);
        List<Animal> list = new ArrayList<>();
        list.add(dog);
        test(list);
    }

    public static  void test(List<Animal> animals) {
        Dog dog = (Dog) animals.get(0);

        System.out.println(dog.getAge());
        System.out.println(dog.getId());
        System.out.println(dog.getName());
    }
}
